﻿package mortal.game.view.autoArena.view
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.display.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.autoArena.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class AutoArenaRoleInfo extends GSprite
    {
        private var _roleName:GTextFiled;
        private var _rank:BitmapNumberText;
        private var _combat:BitmapNumberText;
        private var _challengeBtn:GLoadingButton;
        private var _nameCombatSpr:GSprite;
        private var _clickSpr:GSprite;
        private var _bmp:GBitmap;
        private var _isShowRank:Boolean;
        private var _data:SAutoArenaMinPlayer;

        public function AutoArenaRoleInfo()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._nameCombatSpr = UICompomentPool.getUICompoment(GSprite);
            this.addChild(this._nameCombatSpr);
            this._rank = UIFactory.bitmapNumberText(47, 175 - 3, "AutoArenaRankNum2.png", 20, 24, -10, this, 10, BitmapNumberText.Mid);
            this._rank.text = "";
            this._roleName = UIFactory.gTextField("", -8, 0, 112, 25, this._nameCombatSpr, GlobalStyle.textFormatHuang2.center());
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.AutoArenaCombatTxt, 0, 20, this._nameCombatSpr));
            this._combat = UIFactory.bitmapNumberText(50, 20 + 2, "AutoArenaCombatNum.png", 9, 12, -2, this._nameCombatSpr, 10);
            this._combat.text = "";
            this._clickSpr = UICompomentPool.getUICompoment(GSprite);
            this._clickSpr.mouseEnabled = true;
            this.addChild(this._clickSpr);
            this._bmp = UIFactory.gBitmap(BitmapDataConst.AlphaBMD, 0, 0, this._clickSpr);
            this._bmp.width = 92;
            this._bmp.height = 218;
            this._challengeBtn = UIFactory.gLoadingButton(ResFileConst.AutoArenaChallengeBtn, 21 - 10, 79, 67, 61, this._clickSpr);
            this._challengeBtn.configEventListener(MouseEvent.CLICK, this.onChallengeHandler);
            this._challengeBtn.visible = false;
            this._clickSpr.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._clickSpr.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            return;
        }// end function

        public function set data(param1:SAutoArenaMinPlayer) : void
        {
            this._data = param1;
            if (this._data)
            {
                this._roleName.text = this._data.name;
                this._rank.text = this._data.rank + "";
                this._combat.text = this._data.combat + "";
            }
            else
            {
                this._roleName.text = "";
                this._rank.text = "";
                this._combat.text = "";
            }
            return;
        }// end function

        public function setPos(param1:int) : void
        {
            if (param1 == 0)
            {
                this._nameCombatSpr.y = 0;
            }
            if (param1 == 1)
            {
                this._nameCombatSpr.y = 194;
            }
            return;
        }// end function

        public function set isShowRank(param1:Boolean) : void
        {
            this._isShowRank = param1;
            this._rank.visible = param1;
            return;
        }// end function

        private function onChallengeHandler(event:MouseEvent) : void
        {
            var _loc_2:* = Cache.instance.autoArena.sAutoArenaMyInfo;
            if (_loc_2 == null)
            {
                return;
            }
            var _loc_3:* = Cache.instance.autoArena.sAutoArenaMyInfo.rank;
            var _loc_4:* = Cache.instance.autoArena.currPower;
            var _loc_5:* = this._data.rank;
            if (_loc_4 < 1)
            {
                MsgManager.showRollTipsMsg(Language.getString(40897), MsgRollTipsType.msgRollTips3);
                return;
            }
            if (this._data.name == Cache.instance.role.entityInfo.name)
            {
                MsgManager.showRollTipsMsg(Language.getString(40898), MsgRollTipsType.msgRollTips3);
                return;
            }
            var _loc_6:* = this._data.entityId;
            AutoArenaController.currChallengeEntityId = _loc_6;
            GameProxy.autoArena.autoArenaFight(_loc_3, _loc_6, _loc_5);
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            if (!this._isShowRank)
            {
                return;
            }
            this._challengeBtn.visible = true;
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            if (!this._isShowRank)
            {
                return;
            }
            this._challengeBtn.visible = false;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._roleName.dispose();
            this._roleName = null;
            this._rank.dispose();
            this._rank = null;
            this._combat.dispose();
            this._combat = null;
            this._challengeBtn.dispose();
            this._challengeBtn = null;
            this._nameCombatSpr.dispose();
            this._nameCombatSpr = null;
            this._clickSpr.dispose();
            this._clickSpr = null;
            this._bmp.dispose();
            this._bmp = null;
            this._data = null;
            this._isShowRank = false;
            return;
        }// end function

    }
}
